/*Prepared Using STATA 16: September 16, 2023*/

cap cd ""
use "election_working.dta", clear

/*Appendix B: Awareness of VNA Election in Phase 1 Recruitment*/
tabout electiondateawareness_rc using "Tables\AppendixB_OLSVote", replace cells(freq col) f(0c 2p)

/*Appendix C: Success Rate of Treatment Package Delivery in Phase 2*/
replace p2_physicaldelivery="Fail" if p2_physicaldelivery=="Failed"
replace p2_physicaldelivery="Fail" if p2_physicaldelivery=="N/A"
tabout p2_physicaldelivery treatment_group if control==0 using "Tables\AppendixC_OLSVote", append cells(freq col) f(0c 2p) stats(chi2) 

/*Appendix D: Response Rate for Endline Survey in Phase 3*/
tabout P3 treatment_group using"Tables\AppendixD_OLSVote", append cells(freq col) f(0c 2p) stats(chi2)

/*Appendix E: Differences between Respondents Receiving Follow-Up VNA Questions*/
tabout Questionnaire_order treatment_group using "Tables\AppendixE_OLSVote", append cells (freq col) f(0c 2p) stats(chi2)

/*Appendix I*/
gen yu_aff=0
replace yu=1 if selfingov_yu==1
label val yu_aff polibg2
label var yu_aff "Affiliated with YU?"
tabout politicsinterest_rc yu_aff using "Tables\AppendixI_OLSVote", append cells(freq col) f(0c 2p) stats(chi2)


/*******************************************************************************************************************************************************************************************************************************/

/*Appendix G: Subsetting by whether people voted directy*/

/*OLS Regressions*/

/*Name Candidate*/
reg nameNA T1 T2 T3 if vote_directly==1, robust
outreg2 using "Tables\AppendixG_OLSVote", bdec(3) tdec(3)   e(rmse) noaster  replace label ctitle(Name Candidate - Unadjusted)
reg nameNA T1 T2 T3 i.strata i.major_rc if vote_directly==1, cluster(origin)
outreg2 using "Tables\AppendixG_OLSVote", bdec(3) tdec(3)   e(rmse) noaster  label ctitle(Name Candidate - Block FE)

/*Name Position*/
reg posNA T1 T2 T3 if vote_directly==1, robust
outreg2 using "Tables\AppendixG_OLSVote", bdec(3) tdec(3)   e(rmse) noaster   label ctitle(Name Position - Unadjusted)
reg posNA T1 T2 T3 i.strata i.major_rc if vote_directly==1, cluster(origin)
outreg2 using "Tables\AppendixG_OLSVote", bdec(3) tdec(3)   e(rmse) noaster  label ctitle(Name Position - Block FE)

/*Vote Change*/
reg Q11_7 T1 T2 T3 if vote_directly==1, robust
outreg2 using "Tables\AppendixG_OLSVote", bdec(3) tdec(3)   e(rmse) noaster   label ctitle(Vote Change - Unadjusted)
reg Q11_7 T1 T2 T3 i.strata i.major_rc if vote_directly==1, cluster(origin)
outreg2 using "Tables\AppendixG_OLSVote", bdec(3) tdec(3)   e(rmse) noaster  label ctitle(Vote Change - Block FE)

/*VNA Legitimacy*/
reg VNALegitimacy_all T1 T2 T3 if vote_directly==1, robust
outreg2 using "Tables\AppendixG_OLSVote", bdec(3) tdec(3)   e(rmse) noaster   label ctitle(VNA Legitimacy - Unadjusted)
reg VNALegitimacy_all T1 T2 T3 i.strata i.major_rc if vote_directly==1, vce (cluster origin)
outreg2 using "Tables\AppendixG_OLSVote", bdec(3) tdec(3)   e(rmse) noaster   label ctitle(VNA Legitimacy - Block FE)

/*VNA Legitimacy Dummy*/
reg VNALegitimacy_high T1 T2 T3 if vote_directly==1, robust
outreg2 using "Tables\AppendixG_OLSVote", bdec(3) tdec(3)   e(rmse) noaster   label ctitle(VNA Legitimacy Dummy - Unadjusted)
reg VNALegitimacy_high T1 T2 T3 i.strata i.major_rc if vote_directly==1, vce (cluster origin)
outreg2 using "Tables\AppendixG_OLSVote", bdec(3) tdec(3)   e(rmse) noaster   label ctitle(VNA Legitimacy Dummy - Block FE)

/*VNA Confidence*/
reg VNAConfidence_all T1 T2 T3 if vote_directly==1, robust
outreg2 using "Tables\AppendixG_OLSVote", bdec(3) tdec(3)   e(rmse) noaster   label ctitle(VNA Confidence - Unadjusted)
reg VNAConfidence_all T1 T2 T3 i.strata i.major_rc if vote_directly==1, vce (cluster origin)
outreg2 using "Tables\AppendixG_OLSVote", bdec(3) tdec(3)   e(rmse) noaster   label ctitle(VNA Confidence - Block FE) excel



/*RI P-Values*/
log using "Tables\AppendixG_Pvalue.smcl", replace

/*Name Candidate*/
ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): reg nameNA T1 T2 T3 if vote_directly==1 
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): reg nameNA T1 T2 T3 if vote_directly==1
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): reg nameNA T1 T2 T3 if vote_directly==1 
ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg nameNA  T1 T2 T3 i.major_rc if vote_directly==1 ,absorb(strata) cluster(origin)
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg nameNA  T1 T2 T3 i.major_rc if vote_directly==1 ,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg nameNA  T1 T2 T3 i.major_rc if vote_directly==1,absorb(strata) cluster(origin)

/*Name Position*/
ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): reg posNA T1 T2 T3 if vote_directly==1 
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): reg posNA T1 T2 T3 if vote_directly==1
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): reg posNA T1 T2 T3 if vote_directly==1 
ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg posNA T1 T2 T3 i.major_rc if vote_directly==1,absorb(strata) cluster(origin)
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg posNA T1 T2 T3 i.major_rc if vote_directly==1,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg posNA T1 T2 T3 i.major_rc if vote_directly==1,absorb(strata) cluster(origin)

/*Vote for Change*/
ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): reg Q11_7 T1 T2 T3 if vote_directly==1 
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): reg Q11_7 T1 T2 T3 if vote_directly==1
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): reg Q11_7 T1 T2 T3 if vote_directly==1 
ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg Q11_7 T1 T2 T3 i.major_rc if vote_directly==1,absorb(strata) cluster(origin)
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg Q11_7 T1 T2 T3 i.major_rc if vote_directly==1,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg Q11_7 T1 T2 T3 i.major_rc if vote_directly==1,absorb(strata) cluster(origin)

/*VNA Legitimacy*/
ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): reg VNALegitimacy_all T1 T2 T3 if vote_directly==1 
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): reg VNALegitimacy_all T1 T2 T3 if vote_directly==1
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): reg VNALegitimacy_all T1 T2 T3 if vote_directly==1 
ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg VNALegitimacy_all T1 T2 T3 i.major_rc if vote_directly==1,absorb(strata) cluster(origin)
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg VNALegitimacy_all T1 T2 T3 i.major_rc if vote_directly==1,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg VNALegitimacy_all T1 T2 T3 i.major_rc if vote_directly==1,absorb(strata) cluster(origin)

/*VNA Legitimacy Dummy*/
ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): reg VNALegitimacy_high T1 T2 T3 if vote_directly==1 
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): reg VNALegitimacy_high T1 T2 T3 if vote_directly==1
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): reg VNALegitimacy_high T1 T2 T3 if vote_directly==1 
ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg VNALegitimacy_high T1 T2 T3 i.major_rc if vote_directly==1,absorb(strata) cluster(origin)
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg VNALegitimacy_high T1 T2 T3 i.major_rc if vote_directly==1,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg VNALegitimacy_high T1 T2 T3 i.major_rc if vote_directly==1,absorb(strata) cluster(origin)


/*VNA Confidence*/
ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): reg VNAConfidence_all T1 T2 T3 if vote_directly==1 
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): reg VNAConfidence_all T1 T2 T3 if vote_directly==1
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): reg VNAConfidence_all T1 T2 T3 if vote_directly==1 
ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg VNAConfidence_all T1 T2 T3 i.major_rc if vote_directly==1,absorb(strata) cluster(origin)
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg VNAConfidence_all T1 T2 T3 i.major_rc if vote_directly==1,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg VNAConfidence_all T1 T2 T3 i.major_rc if vote_directly==1,absorb(strata) cluster(origin)
log close

/*******************************************************************************************************************************************************************************************************************************/



/*APPENDIX H: Results Robust to Limiting Analysis to Those with Correct Survey.*/

/*Reason for Voting*/
reg Q11_7 T1 T2 T3 if Questionnaire_order==2, robust
outreg2 using "Tables\AppendixH_OLSLegitimacy", bdec(3) tdec(3)   e(rmse) noaster  replace label ctitle(Change - Unadjusted)
areg Q11_7 T1 T2 T3 i.major_rc if Questionnaire_order==2,absorb(strata) cluster(origin)
outreg2 using "Tables\AppendixH_OLSLegitimacy", bdec(3) tdec(3)   e(rmse) noaster  label ctitle(Change - Block FE)

/*Full Legitimacy*/
reg VNALegitimacy_all T1 T2 T3 if Questionnaire_order==2, robust
outreg2 using "Tables\AppendixH_OLSLegitimacy", bdec(3) tdec(3)   e(rmse) noaster  label ctitle(Legitimacy - Unadjusted)
areg VNALegitimacy_all T1 T2 T3 i.major_rc if Questionnaire_order==2,absorb(strata) cluster(origin)
outreg2 using "Tables\AppendixH_OLSLegitimacy", bdec(3) tdec(3)   e(rmse) noaster  label ctitle(Legitimacy - Block FE)

/*Dichotomous Legitimacy*/
reg VNALegitimacy_high T1 T2 T3 if Questionnaire_order==2, robust
outreg2 using "Tables\AppendixH_OLSLegitimacy", bdec(3) tdec(3)   e(rmse) noaster  label ctitle(Legitimacy_Dummy - Unadjusted)
areg VNALegitimacy_high T1 T2 T3 i.major_rc if Questionnaire_order==2,absorb(strata) cluster(origin)
outreg2 using "Tables\AppendixH_OLSLegitimacy", bdec(3) tdec(3)   e(rmse) noaster  label ctitle(Legitimacy_Dummy - Block FE)

*Confidence in VNA to represent self/community interest
reg VNAConfidence_all T1 T2 T3 if Questionnaire_order==2, robust
outreg2 using "Tables\AppendixH_OLSLegitimacy", bdec(3) tdec(3)   e(rmse) noaster  label ctitle(Confidence - Unadjusted)
areg VNAConfidence_all T1 T2 T3 i.major_rc if Questionnaire_order==2, absorb(strata) cluster(origin)
outreg2 using "Tables\AppendixH_OLSLegitimacy", bdec(3) tdec(3)   e(rmse) noaster  label ctitle(Confidence - Block FE) excel



/*RI P-Values*/
log using "Tables\AppendixH_Pvalue.smcl", replace

/*Reason for Voting*/
ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): reg Q11_7 T1 T2 T3 if Questionnaire_order==2 
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): reg Q11_7 T1 T2 T3 if Questionnaire_order==2 
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): reg Q11_7 T1 T2 T3 if Questionnaire_order==2 
ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg Q11_7 T1 T2 T3 i.major_rc if Questionnaire_order==2,absorb(strata) cluster(origin)
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg Q11_7 T1 T2 T3 i.major_rc if Questionnaire_order==2,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg Q11_7 T1 T2 T3 i.major_rc if Questionnaire_order==2 ,absorb(strata) cluster(origin)

/*Full Legitimacy*/
ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): reg VNALegitimacy_all T1 T2 T3 if Questionnaire_order==2 
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): reg VNALegitimacy_all T1 T2 T3 if Questionnaire_order==2 
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): reg VNALegitimacy_all T1 T2 T3 if Questionnaire_order==2 
ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg VNALegitimacy_all T1 T2 T3 i.major_rc if Questionnaire_order==2,absorb(strata) cluster(origin)
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg VNALegitimacy_all T1 T2 T3 i.major_rc if Questionnaire_order==2,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg VNALegitimacy_all T1 T2 T3 i.major_rc if Questionnaire_order==2,absorb(strata) cluster(origin)

/*Dichotomous Legitimacy*/
ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): reg VNALegitimacy_high T1 T2 T3 if Questionnaire_order==2 
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): reg VNALegitimacy_high T1 T2 T3 if Questionnaire_order==2
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): reg VNALegitimacy_high T1 T2 T3 if Questionnaire_order==2
ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg VNALegitimacy_high T1 T2 T3 i.major_rc if Questionnaire_order==2,absorb(strata) cluster(origin)
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg VNALegitimacy_high T1 T2 T3 i.major_rc if Questionnaire_order==2,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg VNALegitimacy_high T1 T2 T3 i.major_rc if Questionnaire_order==2,absorb(strata) cluster(origin)

*Confidence in VNA to represent self/community interest
ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): reg VNAConfidence_all T1 T2 T3 if Questionnaire_order==2 
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): reg VNAConfidence_all T1 T2 T3 if Questionnaire_order==2 
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): reg VNAConfidence_all T1 T2 T3 if Questionnaire_order==2
ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg VNAConfidence_all T1 T2 T3 i.major_rc if Questionnaire_order==2,absorb(strata) cluster(origin) 
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg VNAConfidence_all T1 T2 T3 i.major_rc if Questionnaire_order==2,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg VNAConfidence_all T1 T2 T3 i.major_rc if Questionnaire_order==2,absorb(strata) cluster(origin)
log close


/********************************************************************************************************************************************/
/*Appendix J*/
log using "Tables\AppendixJ_Pvalue.smcl", replace

/*Age below 40*/
generate age40_dich=0
replace age40_dich=1 if AgeOver40<5 & AgeOver40 !=.
lab var age40_dich "Age Below 40=1"
label define age40_dich 1 ">=1 candidates below 40" 0"No candidates below 40",replace
label val age40_dich age40_dich

reg Vote T1 T2 T3 i.strata i.major_rc if age40_dich==0 , cluster(origin)
outreg2 using "Tables\AppendixJ_Subgroups", bdec(3) tdec(3)   e(rmse)  append ctitle(No below 40yo Candidates) label replace

ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if age40_dich==0,absorb(strata) cluster(origin)
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if age40_dich==0,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if age40_dich==0,absorb(strata) cluster(origin)


reg Vote T1 T2 T3 i.strata i.major_rc if age40_dich==1 , cluster(origin)
outreg2 using "Tables\AppendixJ_Subgroups", bdec(3) tdec(3)   e(rmse)  append ctitle(1+ Age below 40 Candidates) label

ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if age40_dich==1,absorb(strata) cluster(origin)
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if age40_dich==1,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if age40_dich==1,absorb(strata) cluster(origin)

/*Female Candidates on Ballot*/
generate female_dich=Female
replace female_dich=1 if Female>0 & Female !=.
lab var female_dich "Female Candidate on Ballot=1"
label define female_dich 1 "Woman on Ballot" 0"No Women",replace
label val female_dich female_dich

reg Vote T1 T2 T3 i.strata i.major_rc if female_dich==0 , cluster(origin)
outreg2 using "Tables\AppendixJ_Subgroups", bdec(3) tdec(3)   e(rmse)  append ctitle(No Women Candidates) label 

ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if female_dich==0,absorb(strata) cluster(origin)
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if female_dich==0,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if female_dich==0,absorb(strata) cluster(origin)


reg Vote T1 T2 T3 i.strata i.major_rc if female_dich==1 , cluster(origin)
outreg2 using "Tables\AppendixJ_Subgroups", bdec(3) tdec(3)   e(rmse)  append ctitle(1+ Women Candidates) label

ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if female_dich==1,absorb(strata) cluster(origin)
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if female_dich==1,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if female_dich==1,absorb(strata) cluster(origin)


/*VCP member*/
generate VCP_dich=0
replace VCP_dich=1 if VCPMember<5 & VCPMember !=.
lab var VCP_dich "NonVCP member=1"
label define VCP_dich 1 ">=1 nonVCP member candidates" 0"No nonVCP member candidates",replace
label val VCP_dich VCP_dich

reg Vote T1 T2 T3 i.strata i.major_rc if VCP_dich==0 , cluster(origin)
outreg2 using "Tables\AppendixJ_Subgroups", bdec(3) tdec(3)   e(rmse)  append ctitle(No nonVCP member Candidates) label 

ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if VCP_dich==0,absorb(strata) cluster(origin)
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if VCP_dich==0,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if VCP_dich==0,absorb(strata) cluster(origin)


reg Vote T1 T2 T3 i.strata i.major_rc if VCP_dich==1 , cluster(origin)
outreg2 using "Tables\AppendixJ_Subgroups", bdec(3) tdec(3)   e(rmse)  append ctitle(1+ nonVCP member Candidates) label

ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if VCP_dich==1,absorb(strata) cluster(origin)
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if VCP_dich==1,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if VCP_dich==1,absorb(strata) cluster(origin)

/*VNA incumbency*/
generate Incumbent_dich=0
replace Incumbent_dich=1 if IncumbentVNA>1 & IncumbentVNA !=.
lab var Incumbent_dich "Incumbent VNA member=1"
label define Incumbent_dich 1 ">=2 Incumbent VNA member candidates" 0"Only 1 Incumbent VNA member candidates",replace
label val Incumbent_dich Incumbent_dich

reg Vote T1 T2 T3 i.strata i.major_rc if Incumbent_dich==0 , cluster(origin)
outreg2 using "Tables\AppendixJ_Subgroups", bdec(3) tdec(3)   e(rmse)  append ctitle(Only 1 Incumbent VNA member candidates) label 

ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if Incumbent_dich==0,absorb(strata) cluster(origin)
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if Incumbent_dich==0,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if Incumbent_dich==0,absorb(strata) cluster(origin)


reg Vote T1 T2 T3 i.strata i.major_rc if Incumbent_dich==1 , cluster(origin)
outreg2 using "Tables\AppendixJ_Subgroups", bdec(3) tdec(3)   e(rmse)  append ctitle(>=2 Incumbent VNA member candidates) label excel

ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if Incumbent_dich==1,absorb(strata) cluster(origin)
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if Incumbent_dich==1,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if Incumbent_dich==1,absorb(strata) cluster(origin)
log close

/********************************************************************************************************************************************/
/*Appendix K: Voting division*/
log using "Tables\AppendixK_Pvalue.smcl", replace

reg Vote T1 T2 T3 i.strata i.major_rc if votingdivision==1 , cluster(origin)
outreg2 using "Tables\AppendiK_VotingDivision", bdec(3) tdec(3)   e(rmse)  append ctitle(Voting division 1) label replace

ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==1,absorb(strata) cluster(origin)
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==1,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==1,absorb(strata) cluster(origin)


reg Vote T1 T2 T3 i.strata i.major_rc if votingdivision==2, cluster(origin)
outreg2 using "Tables\AppendiK_VotingDivision", bdec(3) tdec(3)   e(rmse)  append ctitle(Voting division 2) label

ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==2,absorb(strata) cluster(origin)
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==2,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==2,absorb(strata) cluster(origin)

reg Vote T1 T2 T3 i.strata i.major_rc if votingdivision==3, cluster(origin)
outreg2 using "Tables\AppendiK_VotingDivision", bdec(3) tdec(3)   e(rmse)  append ctitle(Voting division 3) label

ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==3,absorb(strata) cluster(origin)
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==3,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==3,absorb(strata) cluster(origin)


reg Vote T1 T2 T3 i.strata i.major_rc if votingdivision==4, cluster(origin)
outreg2 using "Tables\AppendiK_VotingDivision", bdec(3) tdec(3)   e(rmse)  append ctitle(Voting division 4) label

ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==4,absorb(strata) cluster(origin)
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==4,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==4,absorb(strata) cluster(origin)


reg Vote T1 T2 T3 i.strata i.major_rc if votingdivision==5, cluster(origin)
outreg2 using "Tables\AppendiK_VotingDivision", bdec(3) tdec(3)   e(rmse)  append ctitle(Voting division 5) label

ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==5,absorb(strata) cluster(origin)
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==5,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==5,absorb(strata) cluster(origin)


reg Vote T1 T2 T3 i.strata i.major_rc if votingdivision==6, cluster(origin)
outreg2 using "Tables\AppendiK_VotingDivision", bdec(3) tdec(3)   e(rmse)  append ctitle(Voting division 6) label

ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==6,absorb(strata) cluster(origin)
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==6,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==6,absorb(strata) cluster(origin)


reg Vote T1 T2 T3 i.strata i.major_rc if votingdivision==7, cluster(origin)
outreg2 using "Tables\AppendiK_VotingDivision", bdec(3) tdec(3)   e(rmse)  append ctitle(Voting division 7) label

ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==7,absorb(strata) cluster(origin)
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==7,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==7,absorb(strata) cluster(origin)


reg Vote T1 T2 T3 i.strata i.major_rc if votingdivision==8, cluster(origin)
outreg2 using "Tables\AppendiK_VotingDivision", bdec(3) tdec(3)   e(rmse)  append ctitle(Voting division 8) label

ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==8,absorb(strata) cluster(origin)
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==8,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==8,absorb(strata) cluster(origin)


reg Vote T1 T2 T3 i.strata i.major_rc if votingdivision==9, cluster(origin)
outreg2 using "Tables\AppendiK_VotingDivision", bdec(3) tdec(3)   e(rmse)  append ctitle(Voting division 9) label

ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==9,absorb(strata) cluster(origin)
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==9,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==9,absorb(strata) cluster(origin)


reg Vote T1 T2 T3 i.strata i.major_rc if votingdivision==10, cluster(origin)
outreg2 using "Tables\AppendiK_VotingDivision", bdec(3) tdec(3)   e(rmse)  append ctitle(Voting division 10) label

ritest T1 _b[T1],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==10,absorb(strata) cluster(origin)
ritest T2 _b[T2],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==10,absorb(strata) cluster(origin)
ritest T3 _b[T3],  kdensityplot reps(1000) seed(125) strata(strata): areg Vote T1 T2 T3 i.major_rc if votingdivision==10,absorb(strata) cluster(origin)
log close
